#!/usr/bin/ksh
###############################################################################
# File: purgelogs.sh
# Desc: Removes logs older than the number of days passed in as first arg
# 
############################################################################### 


if [[ $# < 1 ]]; then   
        echo "Usage $0 DAYS"    
        exit 2
fi      

SERVERS_DIR=/opt/apps/afls/wls103_afls/domains/AflsAdmServer/servers

echo "Looking for logs older than $1 days"
for server in `ls $SERVERS_DIR`
        do
                if [[ $server != "domain_bak" ]]; then
                        find $SERVERS_DIR/$server/logs/ -name '*.log*' -mtime +$1 -exec rm {} \;
                fi
        done